<template>
  <div class="rank-item">
    <div class="rank-item__top">
      <!-- <div class="dot" :style="{ 'background-color': currentColor[1] }"></div> -->
      <div class="dot"></div>
      <!-- <span class="rank">{{ "第" + info.rank + "名" }}</span> -->
      <span class="name">{{ info.name }}</span>
      <span class="value">{{ valueFormat }}万元</span>
    </div>
    <div class="rank-item__bottom">
      <!-- <div
        class="progress"
        :style="{
          width: `${info.percent}`,
          'background-image': `linear-gradient(90deg, ${currentColor[0]} 3%,${currentColor[1]} 100%)`,
        }"
      ></div> -->
    </div>
  </div>
</template>

<script setup>
import { numberFormat } from "@/utils";
import { computed } from "vue";

// const colors = [
//   ["rgba(251, 218, 190, 0.8)", "rgba(204, 110, 38, 1)"],
//   ["rgba(226, 255, 251, 0.8)", "rgba(38, 204, 182, 1)"],
//   ["rgba(231, 246, 253, 0.8)", "rgba(17, 151, 205, 1)"],
//   ["rgba(196, 216, 255, 0.8)", "rgba(54, 113, 232, 1)"],
//   ["rgba(196, 216, 255, 0.8)", "rgba(54, 113, 232, 1)"],
// ];
const props = defineProps({
  info: {
    type: Object,
    default: () => {},
  },
});

const valueFormat = computed(() => {
  return numberFormat(props.info?.value || 0, "1,000.00");
});

// const currentColor = computed(() => {
//   // const index = props.info.rank || 1;
//   return colors[0];
// });
</script>

<style lang="scss" scoped>
.rank-item {
  padding: 8px 0px;
  font-size: 16px;
  color: #ffffff;
  &__top {
    display: flex;
    align-items: center;
    .dot {
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background-color: rgba(54, 113, 232, 1);
    }
    .rank {
      margin-left: 8px;
    }
    .name {
      flex: 1;
      width: 0px;
      margin: 0px 16px;
      text-overflow: ellipsis;
      overflow: hidden;
      word-break: break-all;
      white-space: nowrap;
    }
    .value {
      // width: 150px;
      text-align: right;
    }
  }
  &__bottom {
    margin-top: 8px;
    position: relative;
    background-color: rgba(92, 110, 130, 0.35);
    height: 8px;
    .progress {
      position: absolute;
      height: 100%;
      left: 0px;
      top: 0px;
    }
  }
}
// .rank-item {
//   margin-bottom: 16px;
// }
</style>
